<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@include file="/resource/common/taglib.jspf"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>${SESSION_COMPANY}-系统用户管理</title>
	<%@include file="/resource/common/jquery.jspf"%>
	<%@include file="/resource/common/commonCss.jspf"%>
	<%@include file="/resource/common/bootstrap.jspf"%>
	<%@include file="/resource/common/showLoading.jspf"%>
	<%@include file="/resource/common/tips.jspf"%>
	<script type="text/javascript" src="${ctx }/resource/js/system/user.js"></script>
	<script type="text/javascript" src="${ctxStatic }/js/system/layerParentFn.js"></script>
	<script type="text/javascript">
        var PATH = "${ctx}";
        function addLayerOpen(id,titles){
            titles = id >0?"编辑系统用户："+titles:"新增:系统用户";
            layerParentFn.layerOpenModalDialog(titles,"addSysUserByLayer.do?id="+id,865,600,"inputForm","addSysUserJson.do");
        }

        function addAuth(id){
            var titles = id == 0?"用户授权":"用户授权";
            top.layer.open({
                type: 2,
                title: titles,
                shade: 0.8,//背景色深度
                fixed: false, //不固定
                maxmin: true,
                //closeBtn: 0,
                anim : 1,
                shadeClose: false,//点击其它区域关闭
                content : 'sysUserAuthorityLayer.do?id='+id,
                area: ['865px' , '570px'],
                btn : ["提交",'关闭'],
                yes : function(index,layero){
                    var body = top.layer.getChildFrame('body',index);
                    var iframeWin = layero.find('iframe')[0];//得到iframe页的窗口对像，执行iframe页的方法，iframeWin.method();
                    var inputForm = body.find("#inputForm");
                    if(iframeWin.contentWindow.doSubmit()){
                        var result = 0;
                        var count = 0;
                        //表单提交后，先延时1秒去取异步结果，如果还不成功，再延时3秒去取结果，正常的逻辑时间够了，如果是有大内容就得再回5秒或10秒
                        var tmsg = top.layer.msg('数据开始刷新.......', {time: 100000, icon:6});
                        var tload = top.layer.load(0, {shade: [0.5,'#fff']}); //0代表加载的风格，支持0-2
                        layerParentFn.asyncSaveFormTipMsgLoadClose(iframeWin,index,result,1000,count,tmsg,tload);
                    }
                },
                end: function(index){

                }
            });
        }
	</script>
</head>
<body>
<div id="body-wrapper">
	<div id="main-content">
		<div class="clear"></div>
		<div class="content-box-content">
			<div class="search-box">
				<shiro:hasPermission name="SysUser:SYS_ADD">
					<a href="javascript:void(0)" onclick="addLayerOpen(0,'')" class="btn btn-primary" style="padding-bottom: 0px;padding-top: 0px;line-height: 25px;margin-top: -5px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;新增</a>
				</shiro:hasPermission>
				<hr style="margin-top: 10px;margin-bottom: 10px;">
				<shiro:hasPermission name="SysUser:SYS_SEARCH">
					<form action="" class="form-inline">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">状态</div>
								<select name="enable" id="enable" onchange="search();" class="form-control input-sm">
									<option value="1" <c:if test="${enable==1 }">selected="selected"</c:if>>正常</option>
									<option value="0" <c:if test="${enable==0}">selected="selected"</c:if>>关闭</option>
									<option value="-1" <c:if test="${enable==-1}">selected="selected"</c:if>>所有</option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">帐号</div>
								<input type="text" name="username" id="username" class="form-control"  value="${username}" placeholder="帐号"/>
							</div>
						</div>
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">联系人</div>
								<input type="text" name="contact" id="contact" class="form-control"  value="${contact}" placeholder="联系人"/>
							</div>
						</div>
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">手机号</div>
								<input type="text" name="tel" id="tel" class="form-control"  value="${tel}" placeholder="手机号"/>
							</div>
						</div>
						<button type="button" class="btn btn-sm btn-primary" style="padding-bottom: 3px;" ><i class="fa fa-search"></i>查询</button>
					</form>
				</shiro:hasPermission>
			</div>
			<div class="tab-content default-tab" id="tab1">
				<table class="table table-bordered table-hover">
					<thead>
					<tr>
						<th class="text-center">编号</th>
						<th class="text-center">帐号</th>
						<th class="text-center">联系人</th>
						<th class="text-center">电话</th>
						<th class="text-center">状态</th>
						<th class="text-center">注册时间</th>
						<th class="text-center">修改时间</th>
						<th class="text-center">最后登陆时间</th>
						<th class="text-center">最后登陆IP</th>
						<th class="text-center w210">操作</th>
					</tr>
					</thead>
					<tbody>
					<c:forEach var="sysUser" items="${pageBean.list}" varStatus="abc">
						<tr id="tr_${sysUser.uid}">
							<td class="text-center">${startRow+abc.count}</td>
							<td class="text-center">${sysUser.username}</td>
							<td class="text-center">${sysUser.contact}</td>
							<td class="text-center">${sysUser.tel}</td>
							<td class="text-center">
								<select id="enable" name="enable" onchange="updateStatus(${sysUser.uid},this.value);"  class="form-control input-sm"
									<shiro:lacksPermission name="SysUser:SYS_VERIFY">
										disabled="disabled"
									</shiro:lacksPermission>>
									<option value="1" <c:if test="${sysUser.enable==1}">selected="selected" </c:if>>激活</option>
									<option value="0" <c:if test="${sysUser.enable==0}">selected="selected" </c:if>>禁止</option>
								</select>
							</td>
							<td class="text-center"><fmt:formatDate value="${sysUser.ctime}" pattern="yyyy-MM-dd" /></td>
							<td class="text-center"><fmt:formatDate value="${sysUser.utime}" pattern="yyyy-MM-dd" /></td>
							<td class="text-center"><fmt:formatDate value="${sysUser.ltime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
							<td class="text-center">${sysUser.lip}</td>
							<td class="text-center">
								<shiro:hasPermission name="SysUser:SYS_GRANT"><a href="javascript:void(0);" onclick="addAuth(${sysUser.uid});" class="btn btn-xs btn-primary"><i class="fa fa-cog fa-spin"></i>&nbsp;受权</a> </shiro:hasPermission>
								<shiro:hasPermission name="SysUser:SYS_EDIT"><a href="javascript:void(0)" onclick="addLayerOpen(${sysUser.uid},'${sysUser.username }');" class="btn btn-xs btn-primary"><i class="fa fa-edit"></i>&nbsp;编辑</a> </shiro:hasPermission>
								<shiro:hasPermission name="SysUser:SYS_DELETE"><a href="javascript:layerParentFn.listRowRemoveDeleteByID(${sysUser.uid},'deleteSysUser.do');" class="btn btn-xs btn-danger"><i class="fa fa-trash-o"></i>&nbsp;删除</a></shiro:hasPermission>
							</td>
						</tr>
					</c:forEach>
					</tbody>
					<tfoot>
					<tr>
						<td colspan="10">
							<div class="bulk-actions align-right"></div>
							<div class="paginationstyle">
								<page:pageboot url="sysUserList.do?enable=${enable}&username=${username}&contact=${contact}&" tagnum="2" pageBean="${pageBean}" />
							</div>
							<div class="clear"></div>
						</td>
					</tr>
					</tfoot>
				</table>
			</div>
		</div>
	</div>
</div>
</body>
</html>
